using System.Text;

namespace Axe.Conversions.CustomConverters
{
    internal class StringByteConverter : Conversion<string, byte[]>
    {
        #region Conversion<string,byte[]> Members

        public override byte[] ForwardConvert(string instance)
        {
            if(instance == null)
                return new byte[0];

            return Encoding.Unicode.GetBytes(instance);
        }

        public override string ReverseConvert(byte[] instance)
        {
            if(instance == null)
                return string.Empty;

            return Encoding.Unicode.GetString(instance);
        }

        #endregion
    }
}